<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="../github-markdown.css" />
    <link rel="stylesheet" href="../custom.css" />
    <script src="../custom.js"></script>
    <title>WSL2</title>
  </head>
  <body class="markdown-body">
    <h2>Installation</h2>
    <p>Execute PowerShell script as administrator:</p>
    <ol>
      <li>
        <p>Install HyperV support</p>
        <pre><code>dism /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
</code></pre>
      </li>
      <li>
        <p>Add boot menu entries (Optional):</p>
        <div class="editable">
          <pre><code># choose time
bcdedit /timeout 2
# recommend use legacy boot menu ( which won't boot twice if select not default )
bcdedit /set "{current}" bootmenupolicy legacy

bcdedit /set "{current}" hypervisorlaunchtype off
bcdedit /copy "{current}" /d "HyperV OFF"
bcdedit /set "{current}" hypervisorlaunchtype auto
bcdedit /copy "{current}" /d "HyperV ON"
</code></pre>
        </div>
      </li>
      <li>Reboot</li>
      <li>
        <a href="ms-windows-store://pdp?mode=mini&productId=9P9TQF7MRM4R"
          >Install or Update WSL Kernel</a
        >
      </li>
      <li>
        Optional: enable "Give me updates for other Microsoft products when I
        update Windows" at
        <a href="ms-settings:windowsupdate-options">system settings</a>.
      </li>
    </ol>
    <h2>Usage</h2>
    <p>Import Linux subsystem:</p>
    <div class="editable">
      <pre><code>$vmname = 'alpine'

$fromGzip = Read-Host 'Downloaded image path' | Get-Item
$toDir = Read-Host 'Storage data location' | Get-Item

wsl --import $vmname $toDir $fromGzip
wsl -s $vmname # make it as default subsystem
wsl -d $vmname
</code></pre>
    </div>
    <p>Export:</p>
    <pre><code>wsl --export $vmname "$vmname.tar"</code></pre>
  </body>
</html>
